Skip to content

Update llzk-pod-to-scalar to split pods within arrays to multiple arrays#565

Open
tim-hoffman wants to merge 121 commits into
mainfrom
th/make_pod_to_scalar_split_arrays
Open

Update llzk-pod-to-scalar to split pods within arrays to multiple arrays#565
tim-hoffman wants to merge 121 commits into
mainfrom
th/make_pod_to_scalar_split_arrays

Conversation

@tim-hoffman

Copy link
Copy Markdown
Member

No description provided.

@tim-hoffman
tim-hoffman requested a review from a team as a code owner June 18, 2026 22:55
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Test Results

  2 files  +  1    2 suites  +1   7m 36s ⏱️ + 2m 44s
330 tests + 15  326 ✅ + 15  4 💤 ±0  0 ❌ ±0 
660 runs  +345  652 ✅ +341  8 💤 +4  0 ❌ ±0 

Results for commit 2055a67. ± Comparison against base commit 08360a9.

♻️ This comment has been updated with latest results.

@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 477c5322c0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@tim-hoffman
tim-hoffman requested review from a team and iangneal June 23, 2026 21:10

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45632675f9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
@tim-hoffman
tim-hoffman removed request for a team and iangneal July 13, 2026 15:22
@tim-hoffman
tim-hoffman force-pushed the th/make_pod_to_scalar_split_arrays branch from 7b9bf28 to 7da8b54 Compare July 13, 2026 16:15
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e8722c1ed4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
@tim-hoffman

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 04f30bd9b6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@tim-hoffman
tim-hoffman requested a review from a team July 14, 2026 01:43

@0xddom 0xddom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PodToScalarPass.cpp file is helper functions galore. The code is hard to follow and I think it could be organized a bit better.

Comment thread test/Transforms/PodToScalar/constraints_and_whole_pod_uses.llzk
// CHECK-SAME: %[[ARR_X:[0-9a-zA-Z_\.]+]]: !array.type<2 x index>,
// CHECK-SAME: %[[ARR_Y:[0-9a-zA-Z_\.]+]]: !array.type<2 x !felt.type>,
// CHECK-SAME: %[[ELEM:[0-9a-zA-Z_\.]+]]: !poly.tvar<@E>) attributes {function.allow_constraint} {
// CHECK-NEXT: %[[ELEM_LEAVES:[0-9a-zA-Z_\.]+]]:2 = builtin.unrealized_conversion_cast %[[ELEM]] : !poly.tvar<@E> to index, !felt.type

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this cast can be easily reconciled without special handling since it goes 1:2 in terms of values. What happens if we feed this IR to the flattening pass?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it seems I missed several unrealized_conversion_cast that were left behind and should be handled (if possible).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to leave some unrealized conversions if passes down the line can clear them up

Comment thread test/Transforms/PodToScalar/constraints_and_whole_pod_uses.llzk
Comment on lines +629 to +631
// CHECK-NEXT: %[[VAL_4:[0-9a-zA-Z_\.]+]] = poly.unifiable_cast %[[VAL_0]] : (!array.type<2,? x !poly.tvar<@T>>) -> !array.type<2,? x index>
// CHECK-NEXT: %[[VAL_5:[0-9a-zA-Z_\.]+]] = poly.unifiable_cast %[[VAL_0]] : (!array.type<2,? x !poly.tvar<@T>>) -> !array.type<2,? x !felt.type>
// CHECK-NEXT: %[[VAL_6:[0-9a-zA-Z_\.]+]] = poly.unifiable_cast %[[VAL_0]] : (!array.type<2,? x !poly.tvar<@T>>) -> !array.type<2,? x none>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cast feel wrong when compared to the others

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I thought I fixed that.

// CHECK-LABEL: module attributes {llzk.lang} {
// CHECK-NEXT: function.def @named_array_result
// CHECK-SAME: (%[[VAL_0:[0-9a-zA-Z_\.]+]]: !array.type<2 x index>, %[[VAL_1:[0-9a-zA-Z_\.]+]]: !array.type<2 x !felt.type>)
// CHECK-SAME: -> (!array.type<2 x index> {function.res_name = "out.lhs"}, !array.type<2 x !felt.type> {function.res_name = "out.rhs"}) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may cause issues in llzk-spec since out.lhs is not a valid identifier. I'm not sure what the best solution would be. @iangneal thoughts?

Comment on lines +1920 to +1923
SplitPodArrayNonDetOp, SplitPodArrayCreateArrayOp, SplitPodArrayReadArrayOp,
SplitPodArrayWriteArrayOp, SplitPodArrayExtractArrayOp, SplitPodArrayInsertArrayOp,
SplitPodArrayInFuncDefOp, SplitPodArrayInReturnOp, SplitPodArrayInCallOp,
SplitPodArrayInEmitEqualityOp, SplitPodArrayInEmitContainmentOp, SplitPodArrayLengthOp>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of handling those we should lower them into loops with another pass that should be called before this one if necessary.

Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp Outdated
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp
Comment thread lib/Dialect/POD/Transforms/PodToScalarPass.cpp
Comment thread include/llzk/Dialect/Array/IR/Types.td Outdated
Comment thread test/Transforms/PodToScalar/constraints_and_whole_pod_uses.llzk
// CHECK-SAME: %[[ARR_X:[0-9a-zA-Z_\.]+]]: !array.type<2 x index>,
// CHECK-SAME: %[[ARR_Y:[0-9a-zA-Z_\.]+]]: !array.type<2 x !felt.type>,
// CHECK-SAME: %[[ELEM:[0-9a-zA-Z_\.]+]]: !poly.tvar<@E>) attributes {function.allow_constraint} {
// CHECK-NEXT: %[[ELEM_LEAVES:[0-9a-zA-Z_\.]+]]:2 = builtin.unrealized_conversion_cast %[[ELEM]] : !poly.tvar<@E> to index, !felt.type

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to leave some unrealized conversions if passes down the line can clear them up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants